<?php
 /******************************************************************************
 *   GunCMS is an avid supporter of open source software. This is the appropriate 
 *   option if you are creating an open source application with a license 
 *   compatible with the GNU GPL license v3.
 *   For details http://www.gnu.org/licenses/gpl.html
 *   DO NOT USE FOR COMMERCIAL WITHOUT PERMISSION
 *
 * GunCMS Version 1.0.3
 * Copyright(c) 2009-2010, T & L GdbR
 * info@guncms.de
 * 
 * http://www.guncms.de
 ********************************************************************************/
class FgcmsPage {
	var $db;
 	var $smarty;	
	public function __construct($db, $smarty) {
		//contructor function
		$this->db = $db;
		$this->smarty = $smarty;
	}
	
	/* Assigning the content related to the category_id to the 
	 * Smarty-Variable 'PAGE'. Because using ezSql, PAGE is a pointer!
	 * One should be aware of this fact, when PAGE is used in the 
	 * Smarty-Templates. Output is generated ba: {$PAGE->page_content}.
	 */ 
	public function view_page() {
		if(isset($_GET['subcat']) || isset($_GET['cat'])){
			if(isset($_GET['subcat']) && $_GET['subcat']!="")
				$catid = $_GET['subcat'];
			else
				$catid = $_GET['cat']	;	
			FgcmsGallery::process();	
			$page = FgcmsPageBean::get_page_by_id($this->db,$catid);
			$pagecontent = explode('src="../',$page->page_content);
			$str = "";
			
			for($i=0;$i<count($pagecontent);$i++){
				if($i != 0){
					$text = explode("upload",$pagecontent[$i]);
					$str.='src="upload'.$text['1'];
				}else{
					$str.=$pagecontent[$i];
				}
			}
			$page->page_content = $str;
			$this->smarty->assign('PAGE',$page);	
		}
	}
}
?>
